package com.dialog.suotalib.ring;

import android.content.Context;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Lifecycle;

import com.chaquo.python.PyObject;
import com.chaquo.python.Python;
import com.chaquo.python.android.AndroidPlatform;
import com.dialog.suotalib.utils.L;

public class RingPythonManagement {
    private static Python mPython;
    private static PyObject mPyObject;
    private static RingPythonManagement ringPythonManagement;
    //判断进入手势模式
    public boolean isGoGusture = false;
    public boolean sendState=false;
    public long haveGustureTime =0;
    public  static void init(Context context){
        Python.start(new AndroidPlatform(context));
        mPython = Python.getInstance();
        mPyObject = mPython.getModule("modelToonnx3");
    }
    public static RingPythonManagement getRingPythonManagement() {
        if (ringPythonManagement == null) {
            if (ringPythonManagement == null)
                ringPythonManagement = new RingPythonManagement();
        }
        return ringPythonManagement;
    }
    public Python getmPython() {
        return mPython;
    }

    public void setmPython(Python mPython) {
        this.mPython = mPython;
    }

    public PyObject getmPyObject() {
        return mPyObject;
    }

    public void setmPyObject(PyObject mPyObject) {
        this.mPyObject = mPyObject;
    }

    public boolean isGoGusture() {
        return isGoGusture;
    }

    public long getHaveGustureTime() {
        return haveGustureTime;
    }

    public void setHaveGustureTime(long haveGustureTime) {
        this.haveGustureTime = haveGustureTime;
    }

    private long time = 0;

    public void setGoGusture(boolean goGusture) {
        if (time == 0) {
            isGoGusture = goGusture;
            time = System.currentTimeMillis();
        } else {
            long temp = (System.currentTimeMillis() - time) / 500;
            com.dialog.suotalib.utils.L.i("判断进入手势模式时间差"+System.currentTimeMillis()+"temp="+temp);

            if (temp >= 1) {
                L.i("判断进入手势模式时间差大于0.5秒"+"goGusture="+goGusture);
                isGoGusture = goGusture;
                time = System.currentTimeMillis();
            }
        }

    }    public void setResetGoGusture() {

        isGoGusture = false;
        time = 0;


    }
}
